//
//  DDIconView.m
//  QQZone
//
//  Created by 树清吴 on 2017/10/16.
//  Copyright © 2017年 shuQingWu. All rights reserved.
//

#import "DDIconView.h"

@interface DDIconView ()

@property (nonatomic, strong) UILabel *nameLbl;
@property (nonatomic, strong) UIButton *iconBtn;


@end

@implementation DDIconView

- (void)iconBtnClick:(UIButton *)sender{
    NSLog(@"点击了头像按钮");
}

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = DDGrayColor;
        [self addSubview:self.nameLbl];
        [self addSubview:self.iconBtn];
    }
    return self;
}

- (void)layoutSubviews{
    [super layoutSubviews];
    
    if (DDPortrait) {
        self.nameLbl.hidden = YES;
        self.iconBtn.frame = self.bounds;
        
    }else{
        self.nameLbl.hidden = NO;
        self.iconBtn.x = 0;
        self.iconBtn.y = 0;
        self.iconBtn.width = self.width;
        self.iconBtn.height = self.iconBtn.width;
        
        self.nameLbl.x = 0;
        self.nameLbl.y = self.iconBtn.height;
        self.nameLbl.width = self.width;
        self.nameLbl.height = self.height - self.nameLbl.y;
    }
    
}

#pragma mark -- 懒加载
- (UILabel *)nameLbl{
    if (_nameLbl == nil) {
        
        _nameLbl = [UILabel labelWithTitle:@"天气不错" size:20 textAlignment:NSTextAlignmentCenter color:[UIColor whiteColor]];
        
    }
    return _nameLbl;
}

- (UIButton *)iconBtn{
    if (_iconBtn == nil) {
        _iconBtn = [UIButton buttonWithTitle:nil image:nil highlighted:nil background:@"profile" backgroundHighlighted:nil target:self action:@selector(iconBtnClick:)];
        
    }
    return _iconBtn;
}

@end
